package com.juanjuan.myproject.controller;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.Session;
import java.io.IOException;

/**
 * @ClassName MessageController
 * @Description TODO
 * @Author ZhaoCun
 * @Date 2023/11/1 21:39
 */
@RestController
@CrossOrigin
public class MessageController {
    @RequestMapping("/sendMsg")
    public String sendMsg(String token,String msg) throws IOException {
        Session session = WsServer.clients.get(token);
        session.getBasicRemote().sendText(msg);
        return "发送成功";
    }
}
